﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SharingCenter.Web.Classes;

namespace SharingCenter.Web.Admin.Options
{
    public partial class Terms : AdminPageBase
    {
        protected string q, t;

        public void Page_Init(object sender, EventArgs e)
        {
            if (Request.QueryString["q"] == null || Request.QueryString["t"] == null)
            {
                RedirectToDefaultPage();
            }

            LinkButton1.Click += new EventHandler(LinkButton1_Click);
        }

        void LinkButton1_Click(object sender, EventArgs e)
        {
            SiteConfig.WriteSetting(SiteConfigSection.Misc, q, Editor1.Content);
            SiteConfig.WriteSetting(SiteConfigSection.Misc, t, txtTitle.Text.Trim());
            SiteConfig.SubmitChanges();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            q = Request.QueryString["q"];
            t = Request.QueryString["q"] + "Title";
            if (!IsPostBack)
            {
                Editor1.Content = SiteConfig.ReadSetting(SiteConfigSection.Misc, q);
                txtTitle.Text = SiteConfig.ReadSetting(SiteConfigSection.Misc, t);
            }
        }
    }
}